package com.ruoyi.chiwen.controller;

import java.util.List;

import com.ruoyi.chiwen.domain.TbQualification;
import com.ruoyi.chiwen.service.ITbQualificationService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资质申请Controller
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/system/qualification")
public class TbQualificationController extends BaseController
{
    @Autowired
    private ITbQualificationService tbQualificationService;

    /**
     * 查询资质申请列表
     */
    @PreAuthorize("@ss.hasPermi('system:qualification:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbQualification tbQualification)
    {
        startPage();
        List<TbQualification> list = tbQualificationService.selectTbQualificationList(tbQualification);
        return getDataTable(list);
    }

    /**
     * 导出资质申请列表
     */
    @Log(title = "资质申请", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbQualification tbQualification)
    {
        List<TbQualification> list = tbQualificationService.selectTbQualificationList(tbQualification);
        ExcelUtil<TbQualification> util = new ExcelUtil<TbQualification>(TbQualification.class);
        return util.exportExcel(list, "资质申请数据");
    }

    /**
     * 获取资质申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbQualificationService.selectTbQualificationById(id));
    }

    /**
     * 新增资质申请
     */
    @Log(title = "资质申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbQualification tbQualification)
    {
        return toAjax(tbQualificationService.insertTbQualification(tbQualification));
    }

    /**
     * 修改资质申请
     */
    @Log(title = "资质申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbQualification tbQualification)
    {
        return toAjax(tbQualificationService.updateTbQualification(tbQualification));
    }

    /**
     * 删除资质申请
     */
    @Log(title = "资质申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbQualificationService.deleteTbQualificationByIds(ids));
    }
}
